package cn.gjxblog.service.impl;

import cn.gjxblog.dao.HouseUserMapper;
import cn.gjxblog.model.entity.HouseUser;
import cn.gjxblog.model.entity.HouseUserExample;
import cn.gjxblog.service.HouseUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2018/12/25 16:00
 */
@Service
public class HouseUserServiceImpl implements HouseUserService {

    @Resource
    private HouseUserMapper houseUserMapper;

    @Override
    public HouseUser getByHouseId(String houseId) {
        HouseUserExample houseUserExample = new HouseUserExample();
        houseUserExample.createCriteria().andHouseIdEqualTo(houseId);

        List<HouseUser> houseUsers = houseUserMapper.selectByExample(houseUserExample);

        HouseUser houseUser = houseUsers.stream().findFirst().orElse(null);
        return houseUser;
    }
}
